<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{course_desc}</title>
<link rel="shortcut icon" href="{dir_image}favicon.ico">
<link rel="stylesheet" type="text/css" href="{dir_css}Global.css" />
<link rel="stylesheet" type="text/css" href="{dir_css}Popup.css" />
<link rel="stylesheet" type="text/css" href="{dir_css}Registrar.css" />
<link rel="stylesheet" type="text/css" href="{dir_css}jquery.mCustomScrollbar.css" />

<script type="text/javascript" src="{dir_js}jquery.min.js"></script>
<script type="text/javascript" src="{dir_js}Global.js"></script>
<script type="text/javascript" src="{dir_js}jquery.mCustomScrollbar.concat.min.js"></script>

</head>
<body class="transfery-subject">
	<div class="checklist-header">
		<div><strong>Manuel S. Everga University Foundation - {dept_course}</strong></div>
		<div><strong>{course_desc}</strong></div>
		<div><strong>based on {based}</strong></div>
		<div><strong>Effective SY {year} as per University Curriculum Realignment</strong></div>
	</div>
	<input type="hidden" value="{course_id}" id="course_id"  />
	<input type="hidden" value="{active_subj}" id="active_subj"  />
	<table width="0" border="0" cellspacing="0" cellpadding="0" class="transfery-table-reg" align="left">
		<tr align="center">
			<td class="transfery-td" width="500">DESCRIPTIVE TITLE</td>
			<td class="transfery-td" width="90">COURSE CODE</td>
			<td class="transfery-td" width="94">GRADES</td>
			<td class="transfery-td" width="40"></td>
		</tr>
		<!-- BEGIN semester -->
			<tr class="transfery-tr-semester">
				<td class="transfery-td-semester" align="left" height="14" colspan="4">
				<div class="subj-year-semester">
					{sem_desc}
				</div>
				</td>
			</tr>
			{subject_listing}
			<tr><td class="transfery-td-bot" colspan="4" height="12" align="center"><strong>{sem_note}</strong></td></tr>
		<!-- END semester -->
	</table>
<script type="text/javascript">
	$(document).ready(function() {
		$(".transfery-subject").mCustomScrollbar({
			scrollInertia:120
		});
		
		getRequisiteData();
	});
	
	function getRequisiteData() {
		
		$.post('request.php', {AJAXPost:'requisiteSubjCourse', course_id:$('#course_id').val()}, function(res) {
			
			strArrayActiveSubj = $('#active_subj').val().split('-');
			
			$.each(res, function(first_key, first_value) {
				
				$.each(first_value, function(second_key, second_value) {
					
					strResultInArray = $.inArray(second_value['pre_req'], strArrayActiveSubj);
					
					if(strResultInArray < 0) {
						$('#input_transfer'+second_value['subj_idFK']).addClass('block-input-requisite').attr({'readonly':true, 'onkeypress':'', 'onfocus':''});
					}
					else {
						$('#input_transfer'+second_value['subj_idFK']).removeClass('block-input-requisite').attr({'readonly':false, 'onkeypress':'return numberDate(event, false);', 'onfocus':'viewSaveButton(\'' + second_value['subj_idFK'] + '\')'});
					}
					
				});
				
			});
					
		}, 'json');
	}
	
	function viewSaveButton(strID) {
		$('#save_transfer'+strID).show();
	}
	
	function saveGradeInput(strStud, strSubj, strCourse, strSem, strYear) {
		$('#save_transfer'+strSubj).attr({'src': '{dir_image}icon/loading_round.gif', 'onclick':false});
		if ( $('#input_transfer'+strSubj).val() == '' || $('#input_transfer'+strSubj).val() <= 0 ) {
			$('#input_transfer'+strSubj).addClass('transfery-warning-input');
			$('#save_transfer'+strSubj).attr({'src': '{dir_image}icon/save.png', 'onclick':'saveGradeInput(\'' + strStud + '\', \'' + strSubj + '\', \'' + strCourse + '\', \'' + strSem + '\', \'' + strYear + '\')'});
			return false;
		}
		else {
			$('#input_transfer'+strSubj).removeClass('transfery-warning-input');
			$.post('request.php', {AJAXPost:'SaveTransferyGrades', stud_id:strStud, subj_id:strSubj, course_id:strCourse, sem_id:strSem, year_id:strYear, grades:$('#input_transfer'+strSubj).val(), stud_subj_id:$('#id_transfer'+strSubj).val() }, function(res) {
				$('#id_transfer'+strSubj).val(res.stud_subj_id);
				$('#transfery_grades'+strSubj).text(res.grade_convertion);
				$('#save_transfer'+strSubj).hide();
				$('#active_subj').val($('#active_subj').val() + '-' + strSubj);
				getRequisiteData();
				$('#save_transfer'+strSubj).attr({'src': '{dir_image}icon/save.png', 'onclick':'saveGradeInput(\'' + strStud + '\', \'' + strSubj + '\', \'' + strCourse + '\', \'' + strSem + '\', \'' + strYear + '\')'});
			}, 'json');
			
		}
	}
	
</script>
</body>
</html>